<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link href="https://at.alicdn.com/t/font_1933990_qkjz0pnh8.css" rel="stylesheet">
    <style>

        .icon-Right-:before {
            content: "\e74b";
        }
        *{
            padding: 0;
            margin: 0;
        }
        .container{
            width: 600px;
            height: 300px;
        }
        .nav-wrap{
            width: 100%;
            height: 40px;
            border-bottom: 1px solid #ddd;
            display: flex;
        }
        .item{
            width: 100px;
            height: 100%;
            text-align: center;
            line-height: 40px;
            font-size: 12px;
        }
        .active{
            color: #225af3;
            border-bottom: 1px solid #225af3;
        }
        .item:hover{
            color: #225af3;
            cursor: pointer;
        }
        .content{
            width: 100%;
            height: 300px;
            box-sizing: border-box;
            padding: 20px;
        }
        .url-wrap{
            display: block;
            width: 100%;
            min-height: 200px;
            box-sizing: border-box;
            padding: 10px;
        }
        .utf-wrap{
            display: flex;
            align-items: center;
            width: 100%;
        }
        .utf-item{
            flex: 1;
            min-height: 200px;
            box-sizing: border-box;
            padding: 10px;
        }
        .btn-wrap{
            float: right;
            margin-top: 20px;
        }
        .btn{
            position: relative;
            display: inline-block;
            line-height: 1;
            white-space: nowrap;
            cursor: pointer;
            background: #fff;
            border: 1px solid #dcdfe6;
            color: #606266;
            -webkit-appearance: none;
            text-align: center;
            box-sizing: border-box;
            outline: none;
            margin: 0;
            transition: .1s;
            font-weight: 500;
            padding: 7px 15px;
            font-size: 12px;
            border-radius: 3px;
            color: #fff;
            background-color: #409eff;
            border-color: #409eff;
        }
        .btn:hover{
            background-color: #409effc9;
        }
        .file{
            position: absolute;
            width: 100%;
            height: 100%;
            opacity: 0;
            top: 0;
            left: 0;
            z-index: 1;
        }
    </style>
</head>
<body>
    <div class="container" id="app">
        <div class="nav-wrap">
            <div :class="[index == 0?'item active':'item']" @click="nav_change(0)">二维码生成/解析</div>
            <div :class="[index == 1?'item active':'item']" @click="nav_change(1)">JSON格式化</div>
            <div :class="[index == 2?'item active':'item']" @click="nav_change(2)">base64加密解密</div>
            <div :class="[index == 3?'item active':'item']" @click="nav_change(3)">url编码解码</div>
            <div :class="[index == 4?'item active':'item']" @click="nav_change(4)">UTF-8编码</div>
            <div :class="[index == 5?'item active':'item']" @click="nav_change(5)">颜色转换</div>
        </div>
        <div class="content" v-if="index == 0">
            <div class="utf-wrap">
                <textarea class="utf-item" v-model="content" placeholder="请将您要转换的内容粘贴在这里"></textarea>
                <span style="margin:0 5px" class="iconfont icon-Right-"></span>
                <textarea v-if="!flag" class="utf-item" v-model="res" placeholder="转换结果"></textarea>
                <div v-else class="utf-item" style="border: 1px solid rgb(133,133,133);display: flex;justify-content: center;align-items: center;">
                    <div id="qrcode"></div>
                </div>
            </div>
            <div class="btn-wrap">
                <button class="btn">解析二维码
                    <input
                        @change="upload_pic"
                        class="file"
                        type="file"
                        accept="image/jpg,image/jpeg,image/png,image/PNG,video/mp4"
                    />
                </button>
                <button class="btn" @click="makeQRCode">生成二维码</button>
                <button v-if="!flag" class="btn" id="copy_dom" @click="copy">复制结果</button>
            </div>
        </div>
        <div class="content" v-else>
            <div class="utf-wrap">
                <textarea class="utf-item" v-model="content" placeholder="请将您要转换的内容粘贴在这里"></textarea>
                <span style="margin:0 5px" class="iconfont icon-Right-"></span>
                <textarea class="utf-item" v-model="res" placeholder="转换结果"></textarea>
            </div>
            <div v-if="index == 1" class="btn-wrap">
                <button class="btn" @click="json_parse">JSON格式化</button>
                <button class="btn" id="copy_dom" @click="copy">复制结果</button>
            </div>
            <div v-if="index == 2" class="btn-wrap">
                <button class="btn" @click="base_encode">base64编码</button>
                <button class="btn" @click="base_decode">base64解码</button>
                <button class="btn" id="copy_dom" @click="copy">复制结果</button>
            </div>
            <div v-if="index == 3" class="btn-wrap">
                <button class="btn" @click="url_encode">UrlEncode编码</button>
                <button class="btn" @click="url_decode">UrDecode解码</button>
                <button class="btn" id="copy_dom" @click="copy">复制结果</button>
            </div>
            <div v-if="index == 4" class="btn-wrap">
                <button class="btn" @click="utf_change">中文转UTF-8</button>
                <button class="btn" @click="utf_rechange">UTF-8转中文</button>
                <button class="btn" id="copy_dom" @click="copy">复制结果</button>
            </div>
            <div v-if="index == 5" class="btn-wrap">
                <button class="btn" @click="rgbToHex">rgb转16进制</button>
                <button class="btn" @click="hexToRgba">16进制转rgb</button>
                <button class="btn" id="copy_dom" @click="copy">复制结果</button>
            </div>
        </div>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/clipboard.js/2.0.8/clipboard.min.js"></script>
    <script src="./jsQR.js"></script>
    <script src="./app.js"></script>
</body>
</html>